package com.yq.cp.service.permission.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yq.cp.config.UserThreadLocal;
import com.yq.cp.entity.permission.Permission;
import com.yq.cp.entity.permission.dto.PermissionDto;
import com.yq.cp.mapper.permission.PermissionMapper;
import com.yq.cp.mapper.permission.RoleMapper;
import com.yq.cp.service.permission.PermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zh
 * @since 2022-09-21
 */
@Service
@Transactional
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {

    @Resource
    PermissionMapper permissionMapper;
    @Resource
    RoleMapper roleMapper;
    @Override
    public List<PermissionDto> queryAll(Long pId,Integer type) {
        List<PermissionDto> permissions = permissionMapper.queryAll(pId,type);
        return permissions;
    }

    @Override
    public List<PermissionDto> queryAllByRoleId(Long pId, Long roleId,Integer type) {
        List<PermissionDto> permissions = permissionMapper.queryAllByRoleId(pId,roleId,type);
        return permissions;
    }

    @Override
    public List<PermissionDto> queryAllAndAllot(Long pId, Long roleId,Integer type) {
        List<PermissionDto> permissions = permissionMapper.queryAllAndAllot(pId,roleId,type);
        return permissions;
    }

    @Override
    public List<Permission> selList() {
        List<Permission> permissions =  permissionMapper.selList(UserThreadLocal.get().getId());
        return permissions;
    }
}
